package cn.gorit.admin.controller;

import cn.gorit.admin.service.ResourceService;
import cn.gorit.common.lang.Result;
import cn.gorit.entity.resource.Source;
import cn.gorit.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version v1.0
 * @Classname ResourceController
 * @Description RPC 远程调用资源模块
 * @Author CodingGorit
 * @Created on 2021/4/16 0:20
 * @IDLE IntelliJ IDEA
 **/
@RestController
@RequestMapping("/api/v1/resource")
public class ResourceController {

    @Autowired
    private ResourceService sourceService;

    // 分页查询 Source
    @PostMapping("/back/page/list")
    public Result<Page<Source>> getSourceListByPage(@RequestBody Page<Source> page) {
        return sourceService.getByPage(page);
    }

    // 查看资源
    @GetMapping("/back/detail/{id}")
    public Result<Source> getSoureDetail(@PathVariable("id") Integer id) {
        return sourceService.getSourceById(id);
    }
}
